package com.ruoyi.machine.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.machine.domain.Dto.EExpressBoxUsageRecordsDto;
import com.ruoyi.machine.domain.EExpressBoxUsageRecords;
import com.ruoyi.machine.domain.UseCountMap;
import com.ruoyi.machine.domain.Vo.EExpressBoxUsageRecordsVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;

/**
* @author lenovo
* @description 针对表【express_box_usage_records】的数据库操作Mapper
* @createDate 2024-08-28 18:14:06
* @Entity cn.jy.common.machine.domain.ExpressBoxUsageRecords
*/
@Mapper
public interface EExpressBoxUsageRecordsMapper extends BaseMapper<EExpressBoxUsageRecords> {
    @Select("<script>" +
            "SELECT box_id AS id, COUNT(*) AS useCount " +
            "FROM e_express_box_usage_records " +
            "WHERE box_id IN " +
            "<foreach item='item' index='index' collection='ids' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "GROUP BY box_id" +
            "</script>")
    List<UseCountMap> selectBoxUsageRecords(@Param("ids") ArrayList<Integer> ids);

    List<EExpressBoxUsageRecordsDto> list(EExpressBoxUsageRecordsVo vo);

    Integer count(EExpressBoxUsageRecordsVo vo);

    @Select("<script>" +
            "SELECT box_id AS id, MAX(open_time) AS openDateTime " +
            "FROM e_express_box_usage_records " +
            "WHERE box_id IN " +
            "<foreach item='item' index='index' collection='ids' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "GROUP BY box_id" +
            "</script>")
    List<UseCountMap> findOpenDateTime(@Param("ids") ArrayList<Integer> ids);


    Integer newOpenNum();

    List<EExpressBoxUsageRecords> selectEExpressMachinesList(EExpressBoxUsageRecords records);

}




